import { instance } from '@/utils/http'
const details = {
  namespaced: true,
  state: {
    dataList: null,
    pros: null
  },
  mutations: {
    setDataList (state, value) {
      state.dataList = value
    },
    setPros (state, value) {
      state.pros = value
      state.pros.forEach((item, index, arr) => {
        item.index = index
      })
    }
  },
  actions: {
    getDataList (store, data) {
      instance.get(`appapi/event/product/v3?pageIndex=1&categoryId=${data}&key=&sort=&timestamp=1586439155275&summary=999de9e70f632d284eaa35ccebc77ad8&platform_code=H5`)
        .then(res => {
          this.dataList = res.data

          store.commit('setDataList', res.data)
          store.commit('setPros', res.data.products)
        })
    }
  }
}

export default details
